package com.jieshao

import com.jieshao.rule.convertGitUrl2Https
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.DisplayName
import org.junit.jupiter.params.ParameterizedTest
import org.junit.jupiter.params.provider.CsvSource

class ScriptContextTest {

    @ParameterizedTest(name = "{index} ==> convert ''{0}'' to ''{1}''")
    @DisplayName("testScriptContextMethod")
    @CsvSource(
        "git@github.com:LY1806620741/lineShare.git, https://github.com/LY1806620741/lineShare",
        "https://username:password@github.com/LY1806620741/lineShare.git, https://github.com/LY1806620741/lineShare",
        "git@github.com:500/test.git, https://github.com/500/test",
        "https://foo@bitbucket.org/foo/bar, https://bitbucket.org/foo/bar",
        "ssh://git@stash.example.com:7999/foo/bar.git, https://stash.example.com/foo/bar",
        "git://github.com/foo/bar, https://github.com/foo/bar",
        "ssh://git@custom.gitlab.url:10022/group/project.git, https://custom.gitlab.url/group/project",
        "xy://custom.gitlab.url/group/project.git, https://custom.gitlab.url/group/project",
        "http://LY1806620741@dev.azure.com/LY1806620741/test/_git/test.git, https://dev.azure.com/LY1806620741/test/_git/test.git",
    )
    fun testConvertGitUrl2Https(gitUrl: String, expectedUrl: String) {
        assertEquals(expectedUrl,convertGitUrl2Https(gitUrl))
    }
}